/*
*/

#ifndef coreSensor_h
#define coreSensor_h


#include "../packet_handler/payload_base.hpp"
#include "../packet_handler/payload_headers.hpp"
class CoreSensors : public payloadBase
{
  public:
    CoreSensors() : payloadBase(false, 15) {};
  struct Data {
    short time_stamp;
    unsigned char bumper;
    unsigned char wheel_drop;
    unsigned char cliff;
    short left_encoder;
    short right_encoder;
    char left_pwm;
    char right_pwm;
    unsigned char buttons;
    unsigned char charger;
    unsigned char battery;
    unsigned char over_current;
  } data;

  struct Flags {
    // buttons
    static const unsigned char Button0 = 0x01;
    static const unsigned char Button1 = 0x02;
    static const unsigned char Button2 = 0x04;

    // bumper
    static const unsigned char LeftBumper   = 0x04;
    static const unsigned char CenterBumper = 0x02;
    static const unsigned char RightBumper  = 0x01;

    // cliff sensor
    static const unsigned char LeftCliff    = 0x04;
    static const unsigned char CenterCliff  = 0x02;
    static const unsigned char RightCliff   = 0x01;

    // wheel drop sensor
    static const unsigned char LeftWheel    = 0x02;
    static const unsigned char RightWheel   = 0x01;

    // Charging source
    // - first four bits distinguish between adapter or docking base charging
    static const unsigned char AdapterType  = 0x10;
    // - last 4 bits specified the charging status (see Battery.hpp for details)
    static const unsigned char BatteryStateMask = 0x0F;
    static const unsigned char Discharging  = 0x00;
    static const unsigned char Charged      = 0x02;
    static const unsigned char Charging     = 0x06;

    // wheel drop sensor
    static const unsigned char LeftWheel_OC    = 0x01;
    static const unsigned char RightWheel_OC   = 0x02;

  };

  bool serialise(deque<unsigned char> & byteStream);
  bool deserialise(deque<unsigned char> & byteStream);
};

#endif

